package hello.test;

import hello.service.BaseA;

/**
 * Created by Intellige Idea.
 * Author hiberk
 * Date 2017/6/8 8:59
 */
public class BaseAImpl_2 implements BaseA {
    @Override
    public void out() {
        System.out.println("this is BaseAImpl_2   222222222");
    }
//    public static int ticket = 10;
    public static void main(String[] args) {
        BaseAImpl_2 ab = new BaseAImpl_2();
        BaseAImpl_2.MyThread mt1= ab.new MyThread("一号窗口");
        BaseAImpl_2.MyThread mt2= ab.new MyThread("二号窗口");
        BaseAImpl_2.MyThread mt3= ab.new MyThread("三号窗口");
        mt1.start();
        mt2.start();
        mt3.start();
//        Runnable mt = ab.new MyThread1();
//        Thread thread = new Thread(mt,"一号窗口");
//        Thread thread1 = new Thread(mt,"er号窗口");
//        Thread thread2 = new Thread(mt,"san号窗口");
//        thread.start();
//        thread1.start();
//        thread2.start();
    }
    class MyThread extends Thread {

        private int ticket = 10;
        private String name;
        public MyThread(String name){
            this.name =name;
        }

        public void run(){
            for(int i =0;i<500;i++){
                if(ticket>0){
//                    System.out.println(this.name+"卖票了---->"+(ticket--));
                    System.out.println(Thread.currentThread().getName()+"卖票---->"+(this.ticket--));
                }
            }
        }
    }
    class MyThread1 implements Runnable {
        private int ticket =10;
        private String name;
        public void run(){
            for(int i =0;i<500;i++){
                if(this.ticket>0){
                    System.out.println(Thread.currentThread().getName()+"卖票---->"+(this.ticket--));
                }
            }
        }
    }
}
